package com.wrupple.muba.catalogs.client.module;

import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import com.wrupple.muba.catalogs.client.activity.BrowsingActivity;
import com.wrupple.muba.catalogs.client.activity.CatalogEntryCreateActivity;
import com.wrupple.muba.catalogs.client.activity.CatalogEntryImportActivity;
import com.wrupple.muba.catalogs.client.activity.CatalogEntryReadActivity;
import com.wrupple.muba.catalogs.client.activity.CatalogEntryUpdateActivity;
import com.wrupple.muba.catalogs.client.activity.CatalogSelectionActivity;
import com.wrupple.muba.catalogs.client.activity.impl.CatalogSelectionActivityImpl;
import com.wrupple.muba.catalogs.client.activity.impl.GenericBrowsingActivity;
import com.wrupple.muba.catalogs.client.activity.impl.GenericCreateActivity;
import com.wrupple.muba.catalogs.client.activity.impl.GenericImportActiviy;
import com.wrupple.muba.catalogs.client.activity.impl.GenericReadActivity;
import com.wrupple.muba.catalogs.client.activity.impl.GenericUpdateActivity;
import com.wrupple.muba.catalogs.client.activity.process.impl.ImportDataHandler;
import com.wrupple.muba.catalogs.client.activity.process.state.ContentLoadingState;
import com.wrupple.muba.catalogs.client.activity.process.state.SimpleImportDataHandler;
import com.wrupple.muba.catalogs.client.activity.process.state.impl.ContentLoadingStateImpl;
import com.wrupple.muba.catalogs.client.cms.service.CatalogManagementSystem;
import com.wrupple.muba.catalogs.client.cms.service.impl.GenericCatalogManagementSystem;
import com.wrupple.muba.catalogs.client.cms.service.impl.GenericCatalogManagerImpl;
import com.wrupple.muba.catalogs.client.module.CatalogModule.CatalogModuleController;
import com.wrupple.muba.catalogs.client.module.services.logic.GenericCatalogManager;
import com.wrupple.muba.catalogs.client.module.services.presentation.CatalogPlaceInterpret;
import com.wrupple.muba.catalogs.client.module.services.presentation.impl.MubaCatalogPlaceInterpret;
import com.wrupple.muba.common.client.activity.AbstractDesktopModuleController;
import com.wrupple.muba.common.shared.State.ProcessManager;
import com.wrupple.muba.common.shared.process.impl.SequentialProcessManager;
import com.wrupple.muba.desktop.client.module.DesktopModuleController;
import com.wrupple.muba.widget.client.activity.ActivityPresenter;

public class CatalogWebappConfig extends AbstractGinModule {

	public static class DesktopWidgetProvider implements
			Provider<ActivityPresenter> {

		@Override
		public ActivityPresenter get() {
			return AbstractDesktopModuleController.presenter;
		}

	}

	@Override
	protected void configure() {
		configureDefaultEssentials();
		bind(CatalogManagementSystem.class).to(
				GenericCatalogManagementSystem.class);
	}

	protected void configureDefaultEssentials() {
		// The web application The process manager (only used by the webapp)
		bind(ProcessManager.class).to(SequentialProcessManager.class).in(
				Singleton.class);
		bind(CatalogModuleController.class).to(CatalogController.class);
		bind(CatalogPlaceInterpret.class).to(MubaCatalogPlaceInterpret.class);
		bind(ImportDataHandler.class).to(SimpleImportDataHandler.class);
		bind(BrowsingActivity.class).to(GenericBrowsingActivity.class);
		bind(GenericCatalogManager.class).to(GenericCatalogManagerImpl.class);
		bind(CatalogSelectionActivity.class).to(
				CatalogSelectionActivityImpl.class);
		bind(CatalogEntryCreateActivity.class).to(GenericCreateActivity.class);
		bind(CatalogEntryReadActivity.class).to(GenericReadActivity.class);
		bind(CatalogEntryUpdateActivity.class).to(GenericUpdateActivity.class);
		bind(CatalogEntryImportActivity.class).to(GenericImportActiviy.class);
		bind(ContentLoadingState.class).to(ContentLoadingStateImpl.class);
		bind(DesktopModuleController.class).toProvider(
				DesktopControllerProvider.class);
		bind(ActivityPresenter.class).toProvider(DesktopWidgetProvider.class);
	}
}
